package cn.edu.seu.ssny.dao;

import cn.edu.seu.ssny.dao.support.IBaseDao;
import cn.edu.seu.ssny.entity.Device;
import cn.edu.seu.ssny.entity.Project;
import cn.edu.seu.ssny.entity.StatisticsConfig;
import cn.edu.seu.ssny.entity.StatisticsType;
import cn.edu.seu.ssny.enums.StatisticsEnum;
import org.hibernate.annotations.SQLInsert;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface IStatisticsConfigDao extends IBaseDao<StatisticsConfig, Long> {

    List<StatisticsConfig> findStatisticsConfigsByProjectAndStatisticsTypeId(Project project, Integer statisticsTypeId);

    StatisticsConfig findStatisticsConfigsByProjectAndStatisticsTypeIdAndDevice(Project project, Integer statisticsTypeId, Device device);


    @Query(value = "select device_id from tb_statistics_config where statistics_type_id=?1", nativeQuery = true)
    List<Integer> findDeviceIdsByStatisticsTypeId(Integer statisticsTypeId);

    @Query(value = "select device_id from tb_statistics_config where project_id=?1 and statistics_type_id=?2", nativeQuery = true)
    List<Integer> findDeviceIdsByProjectAndStatisticsTypeId(Integer projectId, int statisticsTypeId);
}
